<!--
 * @Author: zxc
 * @Date: 2020-11-25 09:29:25
 * @LastEditTime: 2020-11-25 09:35:03
 * @LastEditors: zxc
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="button"></button>
  <script>
    Function.prototype.before = function (beforeFn) {
      var _self = this
      return function (...args) {
        if (beforeFn.apply(this, args) === false) {
          return
        }
        return _self.apply(this, args)
      }
    }
    Function.prototype.after = function (afterFn) {
      let _self = this
      return function (...args) {
        let ret = _self.apply(this, args)
        afterFn.apply(this, args)
        return ret
      }
    }
    document.getElementById = document.getElementById.before(function () {
      console.log(2)
    })
    var button = document.getElementById('button')

    console.log(button);
    const a = function () {
      console.log('after test')
    }.after(function () {
      console.log('after')
    }).before(function () {
      console.log('before')
    });
    a()
  </script>
</body>

</html>